package store.lunangangster.engine.impl.query;

import java.util.Date;
import java.util.List;
import store.lunangangster.engine.impl.cmd.CommandExecutor;
import store.lunangangster.engine.impl.entity.DeploymentEntity;
import store.lunangangster.engine.impl.interceptor.CommandContext;

public class DeploymentQueryImpl extends AbstractQuery<DeploymentQuery, DeploymentEntity> implements DeploymentQuery {

  protected String id;
  protected String name;
  protected String nameLike;
  protected String key;
  protected String keyLike;
  protected boolean beforeHasEqual;
  protected boolean afterHasEqual;
  protected Date beforeDate;
  protected Date afterDate;

  public DeploymentQueryImpl(CommandExecutor executor) {
    super(executor);
  }

  @Override
  protected List<DeploymentEntity> queryList(CommandContext commandContext) {
    return (List<DeploymentEntity>) commandContext.getDbSqlSession().selectList("selectDeploymentByCondition", this);
  }

  @Override
  protected Page<DeploymentEntity> queryPage(CommandContext commandContext) {
    return null;
  }

  @Override
  protected int queryCount(CommandContext commandContext) {
    return commandContext.getProcessEngineConfiguration().getDeploymentEntityManager().selectCount(this);
  }

  @Override
  public DeploymentQuery id(String id) {
    this.id = id;
    return this;
  }

  @Override
  public DeploymentQuery name(String name) {
    this.name = name;
    return this;
  }

  @Override
  public DeploymentQuery nameLike(String nameLike) {
    this.nameLike = nameLike;
    return this;
  }

  @Override
  public DeploymentQuery key(String key) {
    this.key = key;
    return this;
  }

  @Override
  public DeploymentQuery keyLike(String keyLike) {
    this.keyLike = keyLike;
    return this;
  }

  @Override
  public DeploymentQuery before(Date date) {
    beforeDate = date;
    beforeHasEqual = false;
    return this;
  }

  @Override
  public DeploymentQuery beforeAndEqual(Date date) {
    beforeDate = date;
    beforeHasEqual = true;
    return this;
  }

  @Override
  public DeploymentQuery after(Date date) {
    afterDate = date;
    afterHasEqual = false;
    return this;
  }

  @Override
  public DeploymentQuery afterAndEqual(Date date) {
    afterDate = date;
    afterHasEqual = true;
    return this;
  }
}
